$(function() {
	var margin = {top: 20, right: 40, bottom: 20, left: 40},
	    width = 960 - margin.right - margin.left,
	    height = 200 - margin.top - margin.bottom;
	
	var x = d3.time.scale()
	.domain(d3.extent(window.sar_data.hits.hits.map(function(d) {
		return d._source.timestamp;
	})))
	.range([0, width]);
	
	var y = d3.scale.linear()
	.domain([0, 100])
    .range([height, 0]);

	var xAxis = d3.svg.axis()
	.scale(x)
	.tickFormat(d3.time.format("%H:%M:%S"));
	
    var yAxis = d3.svg.axis().scale(y);
	
	var svg = d3.select("body").append("svg")
	.attr("width", width + margin.right + margin.left)
	.attr("height", height + margin.top + margin.bottom)
	.append("g")
	.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
	
	svg.append("g")
	.attr("class", "bottom axis")
	.attr("transform", "translate(0," + height + ")")
	.call(xAxis.orient("bottom"));

	svg.append("g")
    .attr("class", "y axis")
    .call(yAxis.orient("left"));
	
	var line = d3.svg.line()
    .interpolate("monotone")
    .x(function(d) { return x(d._source.timestamp); })
    .y(function(d) { return y(d._source.values.tps); });

	  svg.append("path")
      .attr("class", "line")
      .attr("d", line(window.sar_data.hits.hits));	
});
